//index.js
//获取应用实例
var app = getApp();
Page({
  data: {
    webUrl:'',
    user_info:{
    },
    showOpenPartner:0
  },
   //下拉刷新
  onPullDownRefresh: function () {
    console.log("onPullDownRefresh");
    this.onLoad();
  },
  revMsg: function (e) {
    console.log("udexrevMsg", e);
  },
  onShow: function () {
    var reload = app.getPageData("user/index", "reload");
    if (reload) {
      app.setPageData("user/index", { reload: 0 });
      this.onLoad();
    }
  },

  createShare: function () {

    var page = encodeURIComponent('pages/share/index');
    wx.navigateTo({
      url: '/pages/draw/index?page=' + page + "&scene=" + this.data.user_info.user_id,
    })
  },
  tel:function(){
    wx.makePhoneCall({
      phoneNumber: '4008374994', //
      complete: function () {
        
      },
    })
  },

  onLoad: function () {
    var that = this;
    wx.stopPullDownRefresh();
  
    app.getUserInfo((user_info) => {
      that.getUserInfo();
      // this.getPartner();
    });
    
    
  },
  getPartner(){
    var that = this;
    app.api("apiv2/member_partner/find", function (res) {
      var showOpenPartner = 0;
       if(res.data && res.data.status==0){
         showOpenPartner = 1;
       }
      that.setData({ showOpenPartner: showOpenPartner })
    });
  },
  getUserInfo(){
    var that = this;
    app.api("api/user/info", { "fields": "avatarUrl,roleId,user_id,nickname,commission_nums,partner_user_id,phone" }, function (res) {
      if (res.code != 200) {
        app.alert(res.msg);
        return;
      }
      that.setData({
        user_info: res.data
      });
      
    });
  }
})
